﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BLL;
using DAO;

namespace UnitTestProject1
{
    [TestClass]
    public class UserTest
    {
        private UserBLL userBLL;

        [TestInitialize]
        public void MyTestInit()
        {
            userBLL = new UserBLL();

        }
        [TestCleanup]
        public void MyTestClean()
        {
            userBLL = null;
        }

        /// <summary>
        /// check username invalid
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void TestSaveAccount_UserNameIsNull_ThrowException()
        {
            User new_user = new User
            {
                UserName = "",
                FirstName = "",
                LastName = "",
                Email = "",
                PassWord="",
                
            };
            userBLL.SaveUser(new_user,"");
        }
        /// <summary>
        /// check email invalid
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(InvalidCastException))]
        public void TestSaveAccount_EmailInvalid_ThrowException()
        {
            User new_user = new User
            {
                UserName = "123",
                FirstName = "",
                LastName = "",
                Email = "",
                PassWord = "123@",

            };
            userBLL.SaveUser(new_user,"");


        }
    }
}
